package cl.sodexo.com.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public final class FechaUtils {

	/**
	 * @return
	 */
	public static final String fechaDeHoy(){
		return dateFormatStr("dd-MM-yyyy", new Date());
	}
	
	/**
	 * @param format
	 * @param date
	 * @return
	 */
	public static final String dateFormatStr(String format, Date date){
		String fecha = null;
		
		try{
			DateFormat f= new SimpleDateFormat(format);
			fecha 		= f.format(date); 
			
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		return fecha;
	}
	
	/**
	 * @param date
	 * @return
	 */
	public static final Date strToDate(String date){
		SimpleDateFormat formatoDeFecha = new SimpleDateFormat("dd-MM-yyyy");
		
		try {
			return formatoDeFecha.parse(date);
		} catch (Exception e) {
			return null;
		}
	}
	
}
